package com.ruoyi.vplat.websocket.handler;

import java.util.Date;
import java.util.HashMap;

import javax.websocket.Session;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.event.NetworkEvent;
import com.ruoyi.common.utils.JSONUtil;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.common.websocket.handler.AbstractWebsocketMsgHandler;
import com.ruoyi.common.websocket.server.WebSocketUtils;
import com.ruoyi.common.websocket.server.WebsocketServer;
import com.ruoyi.vplat.service.IVplatGatewayService;
import com.ruoyi.vplat.websocket.listener.acs.ACSWsOpenListener;

import lombok.extern.slf4j.Slf4j;

@Component
@Slf4j
public class WebsocketMsgHandler5 extends AbstractWebsocketMsgHandler {
	@Override
	public void invoke(JSONObject message) {
		try {
			JSONObject command = message.getJSONObject("command");
			JSONObject param = message.getJSONObject("param");
			String clientType = command.getString("iProtocol");
			String clientId = command.getString("szClientId");
			int seqNum = command.getIntValue("iSeqNum");
			System.out.println("WebsocketMsgHandler5");
			String gatewayId = null;
			if (clientId.contains("-")) {
				int index = clientId.indexOf("-");
				gatewayId = clientId.substring(index + 1);
			}else {
				gatewayId = clientId;
			}
			//ACSWsOpenListener acs = SpringUtils.getBean(ACSWsOpenListener.class);
			//acs.sendDevicesToGateway(gatewayId, clientId, clientType);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
